﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using System.Runtime;
using System.Runtime.InteropServices;

namespace STT
{
    class hardwareHelper
    {
        
        //枚举主板
        public List<ManagementObject> getMainboard()
        {
            List<ManagementObject> list = new List<ManagementObject>();
            ManagementObjectSearcher query = new ManagementObjectSearcher("select * from Win32_BaseBoard");
            foreach(ManagementObject o in query.Get())
            {
                list.Add(o);
            }
            return list;
        }

        //枚举内存
        public List<ManagementObject> getMemory()
        {
            List<ManagementObject> list = new List<ManagementObject>();
            ManagementObjectSearcher query = new ManagementObjectSearcher("select * from Win32_PhysicalMemory");
            foreach(ManagementObject o in query.Get())
            {
                list.Add(o);
            }
            return list;
        }

        //枚举cpu
        public List<ManagementObject> getCPU()
        {
            List<ManagementObject> list = new List<ManagementObject>();
            ManagementObjectSearcher query = new ManagementObjectSearcher("select * from Win32_Processor");
            foreach (ManagementObject o in query.Get())
            {
                list.Add(o);
            }
            return list;
        }
        
        //枚举声卡
        public List<ManagementObject> getSound()
        {
            List<ManagementObject> list = new List<ManagementObject>();
            ManagementObjectSearcher query = new ManagementObjectSearcher("select * from Win32_SoundDevice");
            foreach(ManagementObject o in query.Get())
            {
                list.Add(o);
            }
            return list;
        }
        
        //枚举显卡
        public List<ManagementObject> getVideo()
        {
            List<ManagementObject> list = new List<ManagementObject>();
            ManagementObjectSearcher query = new ManagementObjectSearcher("select * from Win32_VideoController");
            foreach (ManagementObject o in query.Get())
            {
                list.Add(o);
            }
            return list;
        }
        
        //枚举网卡
        public List<ManagementObject> getNetwork()
        {
            List<ManagementObject> list = new List<ManagementObject>();
            ManagementObjectSearcher query = new ManagementObjectSearcher("select * from Win32_NetworkAdapterConfiguration");
            foreach (ManagementObject o in query.Get())
            {
                list.Add(o);
            }
            return list;
        }

    }
}
